import pygame.mixer #Pygame sound is so much simpler than GStreamer...

class Audio:
    def __init__(self):
        if pygame.mixer.music:
            self.playBGM()
    
    def playBGM(self):
        '''Loops the BGM, waiting until any victory/loss music is complete before starting again.'''
        while pygame.mixer.music.get_busy(): #Wait until the current track finishes...there has to be a better way to do this
            pass
        pygame.mixer.music.load('sound/background.ogg')
        pygame.mixer.music.play(-1) #Loops infinitely
        
    def playWin(self, win):
        pygame.mixer.music.stop()
        print 'Player %d won!' % win
        if not win:
            win = 'sound/win.ogg'
        else:
            win = 'sound/loss.ogg'
        pygame.mixer.music.load(win)
        pygame.mixer.music.play()
        self.playBGM()

class NoneSound:
            def playWin(self, win):
                pass